]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspacesView/workspacesDisplay: Handle smooth events
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Fri, 8 Jan 2021 21:12:52 +0000 (18:12 -0300)
committerMarge Bot <marge-bot@gnome.org>
Thu, 28 Jan 2021 15:11:56 +0000 (15:11 +0000)
On X11, the scroll handler can receive smooth events, which should
trigger a workspace switch. Handle smooth events by checking their
scroll delta, and adjusting the direction depending on these deltas.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1614
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1603>

js/ui/workspacesView.js

index 8fc21c40df36aa6eb91bab4fb5edaf830462d8f7..99a1e65973d8cc55a7b2010e2550cb523efa6563 100644 (file)
@@ -771,11 +771,27 @@ class WorkspacesDisplay extends St.Widget {
         if (event.is_pointer_emulated())
             return Clutter.EVENT_PROPAGATE;
 
+        let direction = event.get_scroll_direction();
+        if (direction === Clutter.ScrollDirection.SMOOTH) {
+            const [dx, dy] = event.get_scroll_delta();
+            if (Math.abs(dx) > Math.abs(dy)) {
+                direction = dx < 0
+                    ? Clutter.ScrollDirection.RIGHT
+                    : Clutter.ScrollDirection.LEFT;
+            } else if (Math.abs(dy) > Math.abs(dx)) {
+                direction = dy < 0
+                    ? Clutter.ScrollDirection.UP
+                    : Clutter.ScrollDirection.DOWN;
+            } else {
+                return Clutter.EVENT_PROPAGATE;
+            }
+        }
+
         let workspaceManager = global.workspace_manager;
         const vertical = workspaceManager.layout_rows === -1;
         let activeWs = workspaceManager.get_active_workspace();
         let ws;
-        switch (event.get_scroll_direction()) {
+        switch (direction) {
         case Clutter.ScrollDirection.UP:
             if (vertical)
                 ws = activeWs.get_neighbor(Meta.MotionDirection.UP);